/**
 * Created by zhangqin on 2017/9/28.
 */
var  ZqShowMap = {

       init : function(map,farmIds,zq_bermudaTriangles,zq_bermudaTriangleCenter,showFarmLand) {
           var infoWindows=[];
        this.clearMap(zq_bermudaTriangles);
        this.clearMap(zq_bermudaTriangleCenter);
           if(showFarmLand) {
               zqPost("/console/wn_farmland/show/json", {farmIds: farmIds}, function (data) {
                   var farmlands = data.data;
                   $(farmlands).each(function (i, o) {
                       var marker = new google.maps.Marker({
                           position: new google.maps.LatLng(o.lat, o.lng),
                           icon: "/static/image/map/farmland.png"
                       });
                       marker.setMap(map);
                       var infoWindow = new google.maps.InfoWindow({
                           content:"<br><div class='markInfo'>农场名称："+o.name+"<hr>农场编号："+o.number+"<hr>农场地址："+o.address+"<br>"
                       });
                       infoWindows.push(infoWindow);
                       google.maps.event.addListener(marker, 'click', function () {
                           closeInfoWindow();
                           infoWindow.open(map, marker);
                       });
                       zq_bermudaTriangleCenter.push(marker);
                       var bermudaTriangle = new google.maps.Polygon({
                           paths: o.list,
                           strokeColor: "#FF0000",
                           //描边的颜色
                           strokeOpacity: 0.8,
                           //描边的透明度
                           strokeWeight: 1,
                           //描边的线宽
                           fillColor: null,
                           //填充的颜色
                           fillOpacity: 0.4,
                           //填充的透明度
                           editable: false,
                           //允许编辑
                           zIndex: google.maps.Marker.MAX_ZINDEX + 3
                       });
                       bermudaTriangle.setMap(map);
                       zq_bermudaTriangles.push(bermudaTriangle);
                   });
               })
           }
           function closeInfoWindow(){
               $(infoWindows).each(function (i,o) {
                   o.close();
               })
           }
    },
     clearMap : function (objs) {
        $(objs).each(function (i,o) {
            o.setMap(null);
        })
        }
}

